<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
  if (window.testRunner) {
    testRunner.overridePreference("WebKitHyperlinkAuditingEnabled", 1);
    testRunner.dumpPingLoaderCallbacks();
  }
  console.error("This test relies on dumping data via `testRunner.dumpPingLoaderCallbacks()`. No URLs containing 'block' should be pinged.");
</script>
</head>
<body>
<script>
  function readableURL(url) {
    return url.replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
  }

  var url_list = [
    // These should load.
    `/resources/square.png?1`,
    `/resources/squ\nare.png?2`,
    `/resources/squ\tare.png?3`,
    `/resources/squ\rare.png?4`,
    `/resources/square.png?img=<&amp;5`,
    `/resources/square.png?img=&lt;&amp;6`,
    `/resources/square.png?img=%3C&amp;7`,
    `/resources/squ\nare.png?img=%3C&amp;8`,
    `/resources/squ\rare.png?img=%3C&amp;9`,
    `/resources/squ\tare.png?img=%3C&amp;10`,
    `/resources/square.png?img=&#10;&amp;11`,
    `/resources/squ\nare.png?img=&#10;&amp;12`,
    `/resources/squ\rare.png?img=&#10;&amp;13`,
    `/resources/squ\tare.png?img=&#10;&amp;14`,

    // These should be blocked.
    `/resources/squ\nare.png?block=<`,
    `/resources/squ\rare.png?block=<`,
    `/resources/squ\tare.png?block=<`,
    `/resources/square.png?<\n=block`,
    `/resources/square.png?<\r=block`,
    `/resources/square.png?<\t=block`,
  ];
  url_list.forEach(url => test(t => {
    var a = document.createElement('a');
    a.ping = self.origin + url;
    a.href = '#' + url;
    document.body.appendChild(a);
    a.click();
  }, "URL: " + readableURL(url)));
</script>
